<template>
	<view>
		<view class="nav">
			<block v-for="(item, index) in menu" :key="index">
				<view class="menu" :data-index="index" :class="index == select ? 'menucolor' : ''" @tap="setNavMenu">
					{{item.text}}
					<view class="line" :class="index == select ? 'menubg' : ''"></view>
				</view>				
			</block>
		</view>
		
		<block v-for="(item, index) in activity1"  v-if="!select">
			<view class="content" :data-url="'/pages/notice/noticecontent?id='+item.id" @click="gotopage">
				<view class="title">{{ item.title }}</view>
				<view class="time">{{ item.date }}</view>
				<image :src="item.image" mode=""></image>
			</view>
		</block>
		<block v-for="(item, index) in activity2" v-if="select">
			<view class="content" :data-url="'/pages/notice/noticecontent?id='+item.id" @click="gotopage">
				<view class="title">{{ item.title }}</view>
				<view class="time">{{ item.date }}</view>
				<image :src="item.image" mode=""></image>
			</view>
		</block>
	</view>
</template>

<script>
export default {
	data() {
		return {
			select:0,
			menu:[
				{
					text:'商城头条',
				},
				{
					text:'新闻资讯',
				}
			],
			activity1: [],
			activity2: [],
		};
	},
	onLoad(e) {
		this.select = 0;
		let me = this;
		me.Net._get('activity1',null,res=>{
			me.activity1 = res.data;
		});
		me.Net._get('activity2',null,res=>{
			me.activity2 = res.data;
		});			
	},
	
	methods: {
		gotopage(e){
			let url = e.currentTarget.dataset.url;
			uni.navigateTo({
				url:url
			})
		},
		setNavMenu(e) {
			let index = e.currentTarget.dataset.index;
			this.select = index;
			console.log(this.select )
		},
	}
};
</script>

<style>
page {
	background-color: #f8f8f8;
	
}

.banner {
	width: 90%;
	margin: 0 auto;
	margin-top: 20px;
	
}

.banner image {
	width: 100%;
}

.content {
	width: 90%;
	margin: 0 auto;
	padding: 10px 0;
	position: relative;
	border-bottom: 1px solid #f5f5f5;
	height: 95px;
}

.content .title {
	font-size: 14px;
	color: #333;
	width: calc(100% - 110px);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
}

.content .time {
	font-size: 10px;
	color: #999;
	width: calc(100% - 110px);
	position: absolute;
	bottom: 10px;
}

.content image {
	width: 100px;
	height: 75px;
	position: absolute;
	right: 0;
	top: 10px;
}


.nav {
	width: 100%;
	height: 50px;
	display: flex;
	justify-content: center;
}

.nav .menu {
	width: 40%;
	height: 50px;
	line-height: 50px;
	font-size: 14px;
	color: #686a7a;
	text-align: center;
	position: relative;
}

.nav .menu .line {
	width: 26px;
	height: 3px;
	background-color: transparent;
	border-radius: 3px;
	position: absolute;
	left: calc(50% - 13px);
	bottom: 0;
}

.menucolor{
	color: #24be9f !important;
	font-size: 30rpx !important;
}

.menubg{
	background-color: #24be9f !important;
}
</style>
